package com.mysoft.gfyx.workbench.controller;

import com.mysoft.framework.modeling.dataapi.DataApi;
import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import com.mysoft.gfyx.workbench.mip.WechatService;
import com.mysoft.gfyx.workbench.mip.dto.GetOpenIdByPhoneRequestDto;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.LinkedHashMap;

@PubService(value = "/wechatPub", prefix = RequestPrefix.PUB, method = RequestMethod.POST)
@Tag(name = "微信控制器-Pub")
public class WechatPubController extends Controller implements DataApi {
    @Resource
    private WechatService wechatService;

    @PubAction(value = "/getOpenId", method = RequestMethod.POST)
    public String getOpenId() {
        GetOpenIdByPhoneRequestDto getOpenIdByPhoneRequestDto = new GetOpenIdByPhoneRequestDto();
        getOpenIdByPhoneRequestDto.setKeyword("test");
        LinkedHashMap result = wechatService.getOpenIdByPhone(getOpenIdByPhoneRequestDto);
        System.out.println("result=====" + result);
        return "testopenid";
    }

    @PubAction(value = "/getQrCode", method = RequestMethod.POST)
    public GetQrCodeResponseDto getQrCode() {
        GetQrCodeResponseDto getQrCodeResponseDto = new GetQrCodeResponseDto();
        getQrCodeResponseDto.setQrCodeUrl("https://jcs.mycaigou.com/res3.0/media/widgets/backTop/wechat-qrcode.png");
        getQrCodeResponseDto.setSceneId("24234s2dfg");
        return getQrCodeResponseDto;
    }
}
